<?php defined('SYSPATH') or die('No direct script access.');
require ('application/classes/dao/base.php');
class Controller_brandm extends Controller {


	public function action_index(){
		echo View::factory('manager/brand');
	}

	public function action_list(){
	}

	public function action_detail(){
		$parm = get($this->request);
		if(!isset($parm['id']) ||($parm['id'])==""){
        	echo "id不能为空";
        }
        $data=rpcCall("brand.detail",$parm);
        echo View::factory('manager/updateBrand')->bind("data",$data);
           
	}
	public function action_getData(){

		$parm = get($this->request);
		if(!isset($parm['page']) ||($parm['page'])==""){
        	echo "page不能为空";
            exit;
        }
        if(!isset($parm['rows']) ||($parm['rows'])==""){
        	echo "rows能为空";
            exit;
        }

        $data=rpcCall("brand.listdata",$parm);
        echo json_encode($data);
	}
	public function action_updateBrand(){
		$parm = post($this->request);
		if(!isset($parm['id']) ||($parm['id'])==""){
        	echo "id不能为空";
            exit;
        }

        $data=rpcCall("brand.update",$parm);
        echo "<script>window.location.href='".Url::base()."index.php/brandm/index'</script>";
	}
	public function action_add(){	
	}
	public function action_addBrand(){
		$parm = post($this->request);
		if(!isset($parm['name']) ||($parm['name'])==""){
        	echo "名称不能为空";
            exit;
        }
      

        $result = rpcCall("brand.add",$parm);
        echo "<script>window.location.href='".Url::base()."index.php/brandm/index'</script>";
	}

	public function action_addDialog(){
		$parm = get($this->request);
		echo View::factory('manager/addBrand');

	}

    public function action_getlist(){

        $parm = get($this->request);
        if(!isset($parm['model']) ||($parm['model'])==""){
            echo "model不能为空";
            exit;
        }
        $result = rpcCall("brand.brandlist",$parm);
        echo json_encode($result);

    }
}
